package com.xxxx.server.utils;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

@Component
@Slf4j
public class GenderJsonDeserializer extends JsonDeserializer {

    @Override
    public List<String> deserialize(JsonParser p, DeserializationContext ctxt)
            throws IOException, JsonProcessingException {
            
        if (ObjectUtils.isEmpty(p)) {
            return null;
        }

            String s = String.valueOf(p);
        String[] s1 = s.split("_");
        List<String> strings = Arrays.asList(s1);

        return strings;
    }
}
